import pytz

from celery import Celery

from scraper import main as scraper_main
from data_statistics import main as data_statistics_main
import utils


app = Celery(
    'scraper_vkusvill',
    broker='redis://localhost:6379/0',
    backend='redis://localhost:6379/0',
    timezone = pytz.timezone('Europe/Moscow')
)

utils.run_necessary_task(app)

@app.task
def get_statistics_of_specified_products() -> None:
    """ Получаем статистику укзанных продуктов """

    # Парсим указанные продукты
    list_of_passed_arguments = utils.InputDataFromUser() \
        .get_list_of_passed_arguments()
    scraper_main.main(
        list_of_passed_arguments.what_parse
    )
    # Отправляем статистику указанных продуктов
    data_statistics_main.main(
        type_of_statistics='specified_products'
    )
